<template>
  <!--  近2周记录-->
  <div class="container-big">
    <div class="header-top">
      <div class="head-title">
        自动推送
      </div>
    </div>
    <div class="content-big">
      <div class="content-left">
        <div class="formGroup">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="130px" class="">
            <el-button type="primary" size="small" @click="handerAddTask" v-hasPermi="['automaticPushList:add']"><i class="el-icon-plus"></i>新建方案</el-button>
            <el-button type="primary" size="small" plain @click="handerSet"><i class="el-icon-setting"></i></el-button>
            <el-form-item prop="userName2">
              <div class="search">
                <el-input v-model="queryParams.userName1" placeholder="搜任务" clearable/>
                <el-button icon="el-icon-search" size="small" @click="handleQuery"></el-button>
              </div>

            </el-form-item>
          </el-form>
        </div>
        <div class="content-item active">
          <div class="content-top">
            <div class="title">方案1_副本</div>
            <div class="mgt"><el-switch
              v-model="value"
              active-color="#13ce66"
              style="transform: scale(0.8)"

            >
            </el-switch>
            </div>
          </div>
           <div class="content-center">
             <div class="center-left">触发标签：孕4周、孕8周、孕12周、孕16周、孕20</div>
             <div class="center-right">2024-03-27 12:00</div>
           </div>
          <div class="content-bottom">
            <div class="content-id">id:1106164</div>
            <div class="content-type">类型：默认</div>
          </div>
        </div>
      </div>
      <div class="content-right">
        <editAutomaticPush></editAutomaticPush>
      </div>
    </div>
    <setSendPage v-if="showSetSendPage" :visableIf.sync="showSetSendPage"></setSendPage>
  </div>
</template>

<script>
import {listUser, delUser,} from "@/api/system/user";

export default {
  name: "automaticPushList",
  components: {
    'editAutomaticPush': () => import('./editAutomaticPush.vue'),//导出弹窗\
    'setSendPage': () => import('./setSendPage.vue'),//导出弹窗\
  },
  data() {
    return {
      showEditName: false,
      showSetSendPage: false,
      showAddOrEditUserOperations: false,
      value: null,
      cities: [{
        value: '0',
        label: '志新'
      }, {
        value: '1',
        label: '锐行'
      }],
      statusList: [
        {
          value: '0',
          label: '所有状态'
        }, {
          value: '1',
          label: '未发布'
        }, {
          value: '2',
          label: '已发布'
        }, {
          value: '3',
          label: '已截止'
        }
      ],
      userList: [
        {
          value: '1',
          label: '已完成'
        }, {
          value: '1',
          label: '未完成'
        }
      ],
      showAddBlackByUser: false,//按客户添加
      showAddEnterpriseBlack: false,//企业自动添加
      showSetClearBlack: false,//应用
      showSetChatBlack: false,//
      active: 0,
      visible: false,
      dateRange1: [],//添加时间
      dateRange2: [],//触发时间
      dialogType: 'add',
      showExportPage: false,//导出
      tableHeight: 600,
      tableDataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        userName2: null,
        pageSize: 10,
        id: null,//用户id
        userName1: null,

      },
      total: 8, // 表格的总条数
    };
  },
  created() {
    // this.getList();
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        label1: '18207418337',
        label2: '18207418337',
        label3: '18207418337',
        label4: '18207418337',
      }
      this.tableDataList.push(obj);
    }
  },
  methods: {
    handerEditName() {
      console.log('111111111111111')
      this.showEditName = true;
    },
    handerSet() {
      console.log('点击数据');
      this.showSetSendPage = true;
    },
    handerClear() {
      console.log('点击');
      this.showSetClearBlack = true;
    },
    handerAddTask() {
      this.$router.push({path: '/IntelligentOperationMgt/automaticPush/addAutomaticPush'})
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(val) {
      this.multipleSelection = [];
      if (val && val.length > 0) {
        val.forEach((item) => {
          this.multipleSelection.push(item.id);
        })
        console.log('multipleSelection', this.multipleSelection);
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      //删除
      // const userIds = row.userId || this.ids;
      // this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项？').then(function () {
      //   return delUser(userIds);
      // }).then(() => {
      //   this.getList();
      //   this.$modal.msgSuccess("删除成功");
      // }).catch(() => {
      // });
      this.$msgBox.showMsgBox({
        title: "是否确认删除？",
        content: "该企微号正在执行服务，删除将会使该号从操作中释放，导致部分功能无法正常使用，请谨慎选择。*如该号已加入在线聊天，成功删除后，聊天记录会被一并删除，重新登录后无法恢复。",
      })
        .then(async (val) => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    handleNumberDelete() {
      this.$modal.confirm('确认清空本页黑名单？').then(function () {
        return delUser(userIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });

    },

  }
};
</script>
<style lang="scss" scoped>
.head-big {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  padding-bottom: 0px;
}

.container-big {
  display: flex;
  height: calc(100vh - 100px);
  margin: 12px;
  flex-direction: column;
}

.content-left {
  width: 400px;
}

.formGroup {
  width: 100%;
  padding: 10px 20px;
  margin-bottom: 10px;
  background: #fff;

  .el-form {
    background: #fff;
    border-radius: 8px;
    margin-top: -1px;
    display: flex;

    .el-button {
      margin-right: 10px;
    }

    .el-form-item {
      margin-bottom: 0px;

      ::v-deep .el-form-item__content {
        display: flex;

        .el-input {
          width: 150px;
        }
      }

      .right-big {
        border-radius: 4px;
        border: 1px solid #DCDFE6;
        padding-left: 11px;

        > span {
          color: #777;
          width: 89px;
          display: inline-block;
          white-space: nowrap;
        }

        .el-select {
          width: 138px;

          ::v-deep .el-input__inner {
            border: none;
          }
        }

        .el-input {
          width: 138px;

          ::v-deep .el-input__inner {
            border: none;
          }
        }

        ::v-deep .el-date-editor {
          border: none;
        }
      }

    }
  }
}


.header-top {
  height: 46px;
  background: #fff;
  border-bottom: 1px solid #e9e9e9;
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 20px;

  .head-title {
    font-size: 14px;
    margin-right: 10px;
    font-weight: bold;
    height: 50px;
    display: flex;
    align-items: center;

    .example-text {
      color: #2f54eb;
      cursor: pointer;
      margin-left: 8px;;
      font-weight: 400;

      &:hover + .example-modal {
        display: block;
      }
    }

    .example-modal {
      position: fixed;
      left: 0;
      margin-top: 10px;
      display: none;
      border-radius: 4px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
      background: #FFFFFF;

      .example-cover {
        height: 600px;
      }
    }
  }

  .divider {
    margin: 0 20px;
    width: 1px;
    height: 16px;
  }
}


.head-right {
  .el-dropdown {
    margin-right: 10px;
  }

  .el-button {
    i {
      margin-right: 5px;
    }
  }
}

.other-option {
  height: 30px;
  display: flex;
  align-items: center;
  color: #2d8cf0;
  font-size: 14px;
  margin-left: 15px;
  border-top: 1px solid #eee;
}

.status {
  &.green {
    color: #1ab394;
  }
}

.content-big {
  .content-left {
    width: 414px;
    display: flex;
    flex-direction: column;

    .content-item {
      background: #fff;
      border-radius: 4px;
      border: 1px solid #e9e9e9;
      cursor: pointer;
      margin: 0px 10px;
      margin-bottom: 10px;

      &.active {
        border: 1px solid #3070ff;
        background: #ebf2ff;
        box-shadow: 0 0 4px 0 rgba(0, 0, 0, .2);
      }

      .content-top {
        display: flex;
        justify-content: space-between;
        olor: rgba(0, 0, 0, .85);
        display: flex;
        align-items: center;
        padding: 12px 12px 5px 12px;

        .title {
          font-size: 14px;
        }

        .mgt {
          font-size: 12px;
          height: 24px;
          display: flex;
          align-items: center;
          border-radius: 5px;


          span {
            margin-right: 5px;
            border-right: 1px solid #eee;
          }
        }
      }

      .content-bottom {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        color: rgba(0, 0, 0, .45);
        padding: 6px 12px;
        border-top: 1px solid #e9e9e9;
      }
    }
  }

  .formGroup {
    display: flex;
  }
}

.content-big {
  display: flex;

  .content-right {
    flex: 1;
    background: #fff;
  }
}
.content-center {
  font-size: 12px;
  color: rgba(0, 0, 0, .45);
  display: flex;
  justify-content: space-between;
  padding: 0px 10px;
  margin-bottom: 10px;
  .center-left {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.search {
  display: flex;

  ::v-deep.el-input__inner {
    border-right: none !important;
    border-radius: 4px 0px 0px 0px;
  }

  ::v-deep .el-button--default {
    border-radius: 0px 4px 4px 0px;
    padding: 0px 10px;
  }
}
</style>
